﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ELearningSystem.Manager.DAO;
using ELearningSystem.Manager.Entities;

namespace ELearningSystem.Manager.Extension_Method
{
    static class DAOExtension
    {
        public static TreeContentDAO ToDAO(this TreeContent treeContent)
        {
            TreeContentDAO treeContentDao = new TreeContentDAO();
            treeContentDao.Id = treeContent.Id;
            treeContentDao.Text = treeContent.Text;
            treeContentDao.Content = treeContent.Content;
            if (treeContent.ParentNode==null)
            {
                treeContentDao.ParentNode = null;
            }
            else
            {
                treeContentDao.ParentNode = treeContent.ParentNode.ToDAO();
            }
            return treeContentDao;
        }
    }
}

